package com.lechuang.system.controller;

import com.lechuang.common.result.Result;
import com.lechuang.system.dto.HomeImgSaveDTO;
import com.lechuang.system.manager.HomeImgManager;
import com.lechuang.system.vo.HomeImgDetailVO;
import com.lechuang.system.vo.HomeImgListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/homeImg")
@Tag(name = "首页轮播图")
public class HomeImgController {
    @Resource
    private HomeImgManager homeImgManager;

    @PostMapping("/list")
    @Operation(summary = "列表")
    public Result<List<HomeImgListVO>> list(){
        List<HomeImgListVO> list = homeImgManager.list();
        return Result.success(list);
    }

    @PostMapping("/delete")
    @Operation(summary = "删除")
    public Result<Object> delete(@RequestParam Long id){
        homeImgManager.delete(id);
        return Result.success();
    }

    @PostMapping("/detail")
    @Operation(summary = "详情")
    public Result<HomeImgDetailVO> detail(@RequestParam Long id){
        HomeImgDetailVO homeImgDetailVO = homeImgManager.detail(id);
        return Result.success(homeImgDetailVO);
    }

    @PostMapping("/saveOrUpdate")
    @Operation(summary = "新增、修改")
    public Result<Object> saveOrUpdate(@RequestBody HomeImgSaveDTO homeImgSaveDTO){
        homeImgManager.saveOrUpdate(homeImgSaveDTO);
        return Result.success();
    }

}
